package mop.exception;

/**
 * Exception class for incorrect users.
 * 
 * @author	 MOP Team 7
 */
public class IllegalUserException extends Throwable 
{

	/**
	 * Initializes an IllegalUserException with the given username
	 * 
	 * @param 	name	The incorrect username.
	 * @effect 	Sets the username.
	 */
	public IllegalUserException(String name)
	{
		this.setUser(name);	
	}
	
	/**
	 * Return a error message that can be used by the gui
	 * @return An error message describing the incorrect name
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append(user + " is not a registrated user!");
		return sb.toString();
		
	}
	
	/**
	 * Set the username.
	 * 
	 * @param 	name	The user that's causing a racket
	 *  
	 * @post 	The user is set to the given one.
	 */
	private void setUser(String name) 
	{
		 this.user = name;
	}
	
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The user(name) thats causing the problem
	 */
	private String user;
	
}